# $NetBSD: Makefile,v 1.36 2023/11/12 13:21:45 wiz Exp $

PKGNAME=	widelands-1.2
DISTNAME=	v${PKGVERSION_NOREV}
CATEGORIES=	games
MASTER_SITES=	https://codeberg.org/wl/widelands/archive/

MAINTAINER=	pkgsrc-users@NetBSD.org
HOMEPAGE=	https://www.widelands.org/
COMMENT=	Fantasy real-time strategy game inspired by Settlers II
LICENSE=	gnu-gpl-v2

USE_CMAKE=	yes
USE_TOOLS+=	pkg-config
USE_TOOLS+=	msgfmt msgmerge pkg-config xgettext
USE_LANGUAGES=	c c++

USE_CXX_FEATURES+=	c++11

CONFIGURE_DIRS=	build
CMAKE_ARG_PATH=	..

CMAKE_ARGS+=	-DWL_INSTALL_BASEDIR=${PREFIX}
CMAKE_ARGS+=	-DWL_INSTALL_DATADIR=${PREFIX}/share/widelands
CMAKE_ARGS+=	-DWL_INSTALL_BINDIR=${PREFIX}/bin
CMAKE_ARGS+=	-DCMAKE_INCLUDE_PATH=${PREFIX}/include/boost
#CMAKE_ARGS+=	-DCMAKE_CXX_FLAGS:STRING=-fsanitize=address
#CMAKE_ARGS+=	-DCMAKE_CXX_FLAGS:STRING=-g
#CMAKE_ARGS+=	-DCMAKE_BUILD_TYPE=RelWithDebInfo
#CMAKE_ARGS+=	-DCMAKE_BUILD_TYPE=Debug

BUILDLINK_TRANSFORM+=	rm:-Werror=shadow

# too much spam from boost headers
BUILDLINK_TRANSFORM+=	rm:-Wold-style-cast
BUILDLINK_TRANSFORM+=	rm:-Wundef

PYTHON_FOR_BUILD_ONLY=	yes

INSTALLATION_DIRS+=	bin
INSTALLATION_DIRS+=	share/doc/widelands

DIST_SUBDIR=	widelands
WRKSRC=		${WRKDIR}/widelands

.include "../../mk/bsd.prefs.mk"

# XXX: The following trick might not work everywhere!
#      Some systems, like Darwin, do not provide pgettext(),
#      and devel/gettext-lib does not provide it either.
pre-configure:
.if ${OPSYS} != "Darwin"
	${PRINTF} '#include <libintl.h>\n' > ${WRKSRC}/src/third_party/gettext/gettext.h
.endif
	${MKDIR} ${WRKSRC}/build

post-install:
	${MV}	${DESTDIR}${PREFIX}/VERSION \
		${DESTDIR}${PREFIX}/ChangeLog \
		${DESTDIR}${PREFIX}/CREDITS \
		${DESTDIR}${PREFIX}/COPYING \
		${DESTDIR}${PREFIX}/share/doc/widelands

.include "../../archivers/minizip/buildlink3.mk"
.include "../../audio/SDL2_mixer/buildlink3.mk"
.include "../../devel/SDL2/buildlink3.mk"
.include "../../devel/boost-headers/buildlink3.mk"
.include "../../devel/boost-libs/buildlink3.mk"
.include "../../devel/zlib/buildlink3.mk"
.include "../../fonts/SDL2_ttf/buildlink3.mk"
.include "../../graphics/hicolor-icon-theme/buildlink3.mk"
.include "../../graphics/SDL2_image/buildlink3.mk"
.include "../../graphics/glew/buildlink3.mk"
.include "../../graphics/png/buildlink3.mk"
.include "../../lang/python/pyversion.mk"
.include "../../sysutils/desktop-file-utils/buildlink3.mk"
.include "../../textproc/icu/buildlink3.mk"
.include "../../mk/pthread.buildlink3.mk"
.include "../../mk/bsd.pkg.mk"
